

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>llvm-extract - extract a function from an LLVM module &#8212; LLVM 9 documentation</title>
    <link rel="stylesheet" href="../_static/llvm-theme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="llvm-bcanalyzer - LLVM bitcode analyzer" href="llvm-bcanalyzer.html" />
    <link rel="prev" title="bugpoint - automatic test case reduction tool" href="bugpoint.html" />
<style type="text/css">
  table.right { float: right; margin-left: 20px; }
  table.right td { border: 1px solid #ccc; }
</style>

  </head><body>
<div class="logo">
  <a href="../index.html">
    <img src="../_static/logo.png"
         alt="LLVM Logo" width="250" height="88"/></a>
</div>

    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="llvm-bcanalyzer.html" title="llvm-bcanalyzer - LLVM bitcode analyzer"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="bugpoint.html" title="bugpoint - automatic test case reduction tool"
             accesskey="P">previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="../index.html">Documentation</a>&raquo;</li>

          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">LLVM Command Guide</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">llvm-extract - extract a function from an LLVM module</a></li> 
      </ul>
    </div>


    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <div class="section" id="llvm-extract-extract-a-function-from-an-llvm-module">
<h1>llvm-extract - extract a function from an LLVM module<a class="headerlink" href="#llvm-extract-extract-a-function-from-an-llvm-module" title="Permalink to this headline">¶</a></h1>
<div class="section" id="synopsis">
<h2>SYNOPSIS<a class="headerlink" href="#synopsis" title="Permalink to this headline">¶</a></h2>
<p><strong class="program">llvm-extract</strong> [<em>options</em>] <strong>–func</strong> <em>function-name</em> [<em>filename</em>]</p>
</div>
<div class="section" id="description">
<h2>DESCRIPTION<a class="headerlink" href="#description" title="Permalink to this headline">¶</a></h2>
<p>The <strong class="program">llvm-extract</strong> command takes the name of a function and extracts
it from the specified LLVM bitcode file.  It is primarily used as a debugging
tool to reduce test cases from larger programs that are triggering a bug.</p>
<p>In addition to extracting the bitcode of the specified function,
<strong class="program">llvm-extract</strong> will also remove unreachable global variables,
prototypes, and unused types.</p>
<p>The <strong class="program">llvm-extract</strong> command reads its input from standard input if
filename is omitted or if filename is <code class="docutils literal notranslate"><span class="pre">-</span></code>.  The output is always written to
standard output, unless the <strong>-o</strong> option is specified (see below).</p>
</div>
<div class="section" id="options">
<h2>OPTIONS<a class="headerlink" href="#options" title="Permalink to this headline">¶</a></h2>
<p><strong>-f</strong></p>
<blockquote>
<div><p>Enable binary output on terminals.  Normally, <strong class="program">llvm-extract</strong> will
refuse to write raw bitcode output if the output stream is a terminal.  With
this option, <strong class="program">llvm-extract</strong> will write raw bitcode regardless of the
output device.</p>
</div></blockquote>
<p><strong>–func</strong> <em>function-name</em></p>
<blockquote>
<div><p>Extract the function named <em>function-name</em> from the LLVM bitcode.  May be
specified multiple times to extract multiple functions at once.</p>
</div></blockquote>
<p><strong>–rfunc</strong> <em>function-regular-expr</em></p>
<blockquote>
<div><p>Extract the function(s) matching <em>function-regular-expr</em> from the LLVM bitcode.
All functions matching the regular expression will be extracted.  May be
specified multiple times.</p>
</div></blockquote>
<p><strong>–glob</strong> <em>global-name</em></p>
<blockquote>
<div><p>Extract the global variable named <em>global-name</em> from the LLVM bitcode.  May be
specified multiple times to extract multiple global variables at once.</p>
</div></blockquote>
<p><strong>–rglob</strong> <em>glob-regular-expr</em></p>
<blockquote>
<div><p>Extract the global variable(s) matching <em>global-regular-expr</em> from the LLVM
bitcode.  All global variables matching the regular expression will be
extracted.  May be specified multiple times.</p>
</div></blockquote>
<p><strong>-help</strong></p>
<blockquote>
<div><p>Print a summary of command line options.</p>
</div></blockquote>
<p><strong>-o</strong> <em>filename</em></p>
<blockquote>
<div><p>Specify the output filename.  If filename is “-” (the default), then
<strong class="program">llvm-extract</strong> sends its output to standard output.</p>
</div></blockquote>
<p><strong>-S</strong></p>
<blockquote>
<div><p>Write output in LLVM intermediate language (instead of bitcode).</p>
</div></blockquote>
</div>
<div class="section" id="exit-status">
<h2>EXIT STATUS<a class="headerlink" href="#exit-status" title="Permalink to this headline">¶</a></h2>
<p>If <strong class="program">llvm-extract</strong> succeeds, it will exit with 0.  Otherwise, if an error
occurs, it will exit with a non-zero value.</p>
</div>
<div class="section" id="see-also">
<h2>SEE ALSO<a class="headerlink" href="#see-also" title="Permalink to this headline">¶</a></h2>
<p><em class="manpage"><a class="manpage reference external" href="https://llvm.org/docs/CommandGuide/bugpoint.html">bugpoint(1)</a></em></p>
</div>
</div>


            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="llvm-bcanalyzer.html" title="llvm-bcanalyzer - LLVM bitcode analyzer"
             >next</a> |</li>
        <li class="right" >
          <a href="bugpoint.html" title="bugpoint - automatic test case reduction tool"
             >previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="../index.html">Documentation</a>&raquo;</li>

          <li class="nav-item nav-item-1"><a href="index.html" >LLVM Command Guide</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">llvm-extract - extract a function from an LLVM module</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2003-2020, LLVM Project.
      Last updated on 2020-09-20.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
    </div>
  </body>
</html>